home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / os2 / pmcstex.zip / PM_BINS.ZIP / PMTEXIT.CMD < prev    next >
OS/2 REXX Batch file  |  1996-03-01  |  3KB  |  90 lines

  1. /* pmTeXit.cmd: according to                                   */
  2. /* texit.cmd -- Copyright (c) 1992, 1994 by Eberhard Mattes    */
  3.  
  4. /*   
  5.   Changed by Petr Mikulik (3.11.1995 and 29.2.1996) in order to 
  6.   accept  Format:  and  Master:  notation of CSTeX for EPM. 
  7.  
  8.    Example: you have the first line of your tex document mytext.tex:
  9.       % Format: latex209 Master: a.tex
  10.    Thus the command   
  11.       pmtexit mytext.tex   
  12.    runs
  13.       latex209.cmd a.tex 
  14.    If  % Format:  is not specified, then the environmental variable 
  15.    TEXFORMATDEFAULT is substituted, and even this does not exist, then
  16.    latex is used                           
  17.  
  18.    Bugs: Format is taken from 'slave' file, not from Master. This is 
  19.      contrary to CSTeX for EPM package. I use only latex (or cslatex) 
  20.      so I do not bother about it. If someone needs to change the code 
  21.      in order to read the first line of Master, send me the corrected file
  22. */
  23.  
  24. /* Original note by Eberhard Mattes:                           */
  25. /* Choose TeX format according to first line of TeX input file */
  26. /* Call editor if TeX has been left by answering `E'.          */
  27.  
  28. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  29. call SysLoadFuncs
  30. format = ''; options = ''
  31. parse arg arg1 rest
  32. do while (length( arg1) >= 2) & ((substr( arg1, 1, 1) = '-') |,
  33.                                  (substr( arg1, 1, 1) = '/'))
  34.   options = options arg1
  35.   parse var rest arg1 rest
  36. end
  37. if (length( arg1) >= 2) & ((substr( arg1, 1, 1) = '&') |,
  38.                            (substr( arg1, 1, 2) = '^&')) then
  39. do
  40.   format = arg1
  41.   parse var rest arg1 rest
  42. end
  43. if (format = '') & (length( arg1) >= 1) & \ (substr( arg1, 1, 1) = '\') then
  44. do
  45.   input = arg1
  46.   master = arg1
  47.   fname = filespec( 'name', input)
  48.   parse var fname base '.' ext
  49.   if ext = '' then
  50.     input = input'.tex'
  51.   fname = stream( input, 'C', 'QUERY EXISTS')
  52.   if fname = '' then
  53.     fname = SysSearchPath( 'TEXINPUT', input)
  54.   if \ (fname = '') then
  55.   do
  56.     /* read Master */
  57.     line = linein( fname)
  58.     uline = translate(line)
  59.     call stream fname, 'C', 'CLOSE'
  60.     /* say 'First line =' line */
  61.     /*    parse var line '%' 'MASTER:' master . */
  62.     w=words(line); 
  63.     i=wordpos('MASTER:',uline)
  64.     if (i>0) & (i<w) then master=word(line,i+1)
  65.     i=wordpos('MASTER',uline)
  66.     if (i>0) & (i<w) then master=word(line,i+1)
  67.     if (master = '') then master = arg1
  68.     /* read Format */
  69.     if (format='') then do
  70.       i=wordpos('FORMAT:',uline) 
  71.       if (i>0) & (i<w) then format=word(line,i+1)
  72.       end
  73.     if (format='') then do
  74.       i=wordpos('FORMAT',uline) 
  75.       if (i>0) & (i<w) then format=word(line,i+1)
  76.       end
  77.     if (format='') then format=value('TEXFORMATDEFAULT',, 'OS2ENVIRONMENT')
  78.     if (format='') then format='latex'
  79.   end
  80. end
  81. tmpfile = SysTempFileName('texit???.cmd')
  82. cmd.exe '/c' format master rest
  83. if \ (stream( tmpfile, 'C', 'QUERY EXISTS') = '') then
  84. do
  85.   '@call' tmpfile
  86.   '@del' tmpfile
  87. end
  88.  
  89. /* End of pmtexit.cmd */
  90.